package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.MybatisConfig;
import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Service
@Transactional //事务管理
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;

    @Override
    public void add(StudentBean student) {
        mapper.add(student);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, String newTel) {
        mapper.update(id,newTel);
    }

    @Override
    public List<StudentBean> findAll() {
        List<StudentBean> list = mapper.findAll();
        return list;
    }

    @Override
    public PageInfo<StudentBean> cutAll(int pageNO) {
        PageHelper.startPage(pageNO,3);
        PageInfo<StudentBean> pageInfo = PageInfo.of(mapper.findAll());
        return pageInfo;
    }

}
